import { $http } from '@escook/request-miniprogram';
import store from '@/store/store.js';
// 配置接口的基础路径
// $http.baseUrl = 'https://api-ugo-web.itheima.net';
$http.baseUrl = 'https://api-hmugo-web.itheima.net';

// 配置请求前要执行的操作
$http.beforeRequest = function(options) {
	uni.showLoading({
		title: '数据加载中...',
		mask: true
	});
	// console.log(options);
	if (options.url.includes('/my/')) {
		options.header = {
			Authorization: store.state.m_user.token
		};
	}
};

// 配置请求后要执行的操作
$http.afterRequest = function(res) {
	uni.hideLoading();
};

// 将$http挂载到uni全局对象
uni.$http = $http;
